$(function () {
    /*$("#select1").click(function () {
        $.ajax({
            type:"get",
            url:"http://localhost:10000/ruku2/select.do",
            success:function(data){
                $("#select1").html("");
                for (let i = 0; i < data.length; i++) {
                    if (){

                    }
                    $("#select1").append("<option th:if=''>"+data[i].storeName+"</option>")
                }
            }
        })
    })*/
    $("#select1").click(function () {
        var cangwei = $("#select1").val()
        $.ajax({
            type:"get",
            url:"http://localhost:10000/ruku2/select.do",
            dataType:"json",
            data:"storeid=" + cangwei,
            success:function(data){
                console.log("1")
                $("#select2").html("");
                for (let i = 0; i < data.length; i++) {
                    $("#select2").append("<option>"+data[i].siteID+"</option>")
                }
            }
        })
    })
})
$(function () {
    $(".checkname").click(function () {
        var billid = $(this).parents("td").parents("tr").children("td").eq(2).html();
        $.ajax({
            type:"get",
            url:"http://localhost:10000/ruku2/getAll.do",
            dataType:"json",
            data:"billID=" + billid,
            success:function(data){
                $("#smalltable").html("")
                for (let i = 0; i < data.length; i++) {
                    $("#huozhu").val(data[i].wmsTBill.wmsTCustomer.custName)
                    $("#billid").val(data[i].wmsTBill.billID)
                    $("#billdate").val(data[i].wmsTBill.billDate)
                    $("#smalltable").append("<tr>\n" +
                        "            <td>"+data[i].trayID+"</td>\n" +
                        "            <td>"+data[i].detailsGoodsName+"</td>\n" +
                        "            <td>"+data[i].detailsGoodsSpec+"</td>\n" +
                        "            <td>"+data[i].detailsGoodsNum+"</td>\n" +
                        "            <td>"+data[i].detailsGoodsSpec*data[i].detailsGoodsNum+"</td>\n" +
                        "            <td>"+data[i].detailsAffirmant+"</td>\n" +
                        "        </tr>")
                    $("#alljianshu").html(data[i].detailsGoodsNum)
                    $("#lizi").val(data[i].wmsTBill.billFeeTruckage)
                    $("#qita").val(data[i].wmsTBill.billFeeOther)
                    $("#kucun").val(data[i].wmsTBill.billFeeStore)
                    $("#hejiyingshou").val(data[i].wmsTBill.billPayable)
                    $("#hejishishou").val(data[i].wmsTBill.billPaid)
                }
            }
        })
    })
})
$(function () {
    $("#selectruku").click(function () {
        var start = $("#start").val()
        var end = $("#end").val()
        var billID = $("#billID").val()
        var custName = $("#custName").val()

        window.location = "http://localhost:10000/rukuu/selectmingxi2.do?start="+start+"&end="+end+"&billID="+billID+"&custName="+custName;
    })
})
function getpage(page) {
    var start = $("#start").val()
    var end = $("#end").val()
    var billID = $("#billID").val()
    var custName = $("#custName").val()
    var pagesize = $("#size").val();
    var pageNum = $("#num").val();
    window.location = "http://localhost:10000/rukuu/selectmingxi2.do?custName=" + custName +
            "&start=" + start + "&pageNum=" + pageNum + "&end=" + end+"&billID"+ billID + "&pageSize=" + page;
}

function lastpage(page) {
    var start = $("#start").val()
    var end = $("#end").val()
    var billID = $("#billID").val()
    var custName = $("#custName").val()
    var pagesize = $("#pageSize").val();
    window.location = "http://localhost:10000/rukuu/selectmingxi2.do?custName=" + custName +
            "&start=" + start + "&pageNum=" + page + "&end=" + end+"&billID"+ billID + "&pageSize=" + pagesize;
}